-
-
Notifications
You must be signed in to change notification settings - Fork 344
New Security Considerations #1618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
specs/jsonschema-core.md
Outdated
recursive schemas create loops, but implementations are advised to detect and | ||
break these cycles when they are encountered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier in the spec, implementations are required to halt when encountering infinite cycles.
How would one break such a cycle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't intend to imply that one could somehow continue evaluating the schema. I'll reword to make it more clear that it should stop evaluation when it detects a cycle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one comment, otherwise 👍🏼
specs/jsonschema-core.md
Outdated
Implementations should consider rejecting schemas that have identifiers | ||
(including embedded schema identifiers) that conflict with registered schemas | ||
and should apply consistent URI normalization and comparison logic to detect and | ||
prevent conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would we not want to allow that? I think we should upgrade this to a MUST.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think (not in front of a computer currently) that normalization is a requirement of the sections on reference resolution.
That said, I wouldn't be opposed to being more strict around preventing overwrites.
Would a MUST-level requirement be appropriate here, or would it fit more in one of the main body sections?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all ...
Would a MUST-level requirement be appropriate here, or would it fit more in one of the main body sections?
Right. The Security Considerations section should be an analysis of the security considerations both mitigated and not mitigated by requirements as defined in the specification. It should not make normative statements, but can reference parts of the spec that do.
When would we not want to allow that? I think we should upgrade this to a MUST.
There are two "shoulds" in this sentence, so I'm not sure which one (or both) are being referred to.
Implementations should consider rejecting schemas that have identifiers (including embedded schema identifiers) that conflict with registered schemas
A reasonable alternative could be to ignore the schema and use the registered one instead (perhaps with a warning). A scenario where I think this might make sense is with a bundled schema that includes a common schema because it might be used in a variety of implementations and doesn't know if the schema will be registered or not. If the implementation doesn't have that schema registered, then it's available in the bundle. If the implementation does have it registered, it should use the registered version. I think there's a variety of different situations and use cases where not rejecting the schema could make sense. I'd like implementations to be able to provide users with the ability to choose how this should be handled. But, suggesting that they should be rejected is, I think, I good "secure by default" behavior.
and should apply consistent URI normalization and comparison logic to detect and
prevent conflicts.
Looking into this, I just noticed the following from RFC 3987
Applications using IRIs as identity tokens with no relationship to a protocol MUST use the Simple String Comparison (see section 5.3.1). All other applications MUST select one of the comparison practices from the Comparison Ladder (see section 5.3
JSON Schema describes our use of IRIs as identity tokens, not locators, which means implementations should limit themselves to Simple String Comparison. That's not what our spec currently says. It says to use the normalization procedure defined in 5.3, which isn't quite correct either. We'd need to be more specific about which comparisons to use. For example, we wouldn't require scheme-based or protocol-based normalization because it would be too onerous a requirement for implementers to implement scheme-based requirements for any scheme they might encounter.
From a security perspective, it doesn't matter what normalization is performed, only that it's consistent. Maybe that's the update we should make for now and discuss what comparison/normalization should be required in the spec in a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can think of a clear usecase for this.
It may be that implementations have chosen poor architecture and only allow a single instance of the implementation.
Say I have a JSON Schema, and I want to evaluate the outcome if I change a part of one of the referenced schemas? If it was already registered with an ID, and I want to override that, I should be able to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that comes down to an implementation option to allow it. The default behavior should be to reject an overwrite attempt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good. Thanks for your work on this. Sorry for the delay in reviewing.
It seems like it might be incorrect for us to suggest that implementers to normalize identifiers (see #1618 (comment)) For now, I made a slight change to the wording about URI normalization and I suggest we merge now and consider the question of normalization separately. I'll create a follow up issue. |
specs/jsonschema-core.md
Outdated
### Vocabulary-Specific Risks | ||
|
||
Third-party JSON Schema vocabularies may introduce additional risks. | ||
Implementers are advised to consult the specifications of any extensions they | ||
support and take into account their security considerations as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update this to use "extension" language since we've removed "vocabulary".
Resolves #1231
Replaces #1600
This is a full rewrite of the Security Considerations sections of the Core spec. It retains most of the original content plus a lot more. The only thing I left out from the original is the part about
$comment
, which I don't think makes sense. If there's an argument for keeping it, I can add it back in.This new Security Consideration section is inspired by the guidelines and examples in RFC 3552 - Guidelines for Writing RFC Text on Security Considerations. Some principles I'm trying to follow are,
Something worth mentioning is that this PR advises not to use
file:
URIs in$id
. However, we use file URIs in a couple tests in the official test suite. We should consider changing, removing, or moving those tests to optional.